package com.naire.modul.questionnaire.action;

import net.common.action.GeneralAction;

import com.naire.modul.questionnaire.service.QuestionnaireCreateService;
import com.naire.modul.questionnaire.service.QuestionnaireDeleteService;
import com.naire.modul.questionnaire.service.QuestionnaireEditorService;
import com.naire.modul.questionnaire.service.QuestionnaireFindService;
import com.naire.modul.questionnaire.vo.Projeckpi_answerVo;

public class QuestionnaireAction extends GeneralAction {

	private static final long serialVersionUID = -1445919867214555808L;
	private Integer project_id;
	private String code;
	private Projeckpi_answerVo bean = new Projeckpi_answerVo();
	
	public String forward() throws Exception {
		return SUCCESS;
	}
	
	public String addQuestionnairePage() throws Exception {
		Integer project_answer_id = bean.getProject_answer_id();
		if(project_answer_id != null) {
			QuestionnaireFindService service = new QuestionnaireFindService();
			service.setProject_answer_id(project_answer_id);
			service.invoke();
			bean = service.getBean();
		}
		return SUCCESS;
	}
	
	public String addQuestionnaire() throws Exception {
		QuestionnaireEditorService service = new QuestionnaireEditorService();
		service.setBean(bean);
		service.setCode(code);
		service.setProject_id(project_id);
		service.invoke();
		return SUCCESS;
	}
	
	public String removeQuestionnaire() throws Exception {
		Integer project_answer_id = bean.getProject_answer_id();
		QuestionnaireDeleteService service = new QuestionnaireDeleteService();
		service.setProject_answer_id(project_answer_id);
		service.invoke();
		return SUCCESS;
	}

	public void createQuestionnaire() throws Exception {
		QuestionnaireCreateService service = new QuestionnaireCreateService();
		service.setProject_id(project_id);
		service.invoke();
		out(service.getHtml());
	}

	public Integer getProject_id() {
		return project_id;
	}

	public void setProject_id(Integer project_id) {
		this.project_id = project_id;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Projeckpi_answerVo getBean() {
		return bean;
	}

	public void setBean(Projeckpi_answerVo bean) {
		this.bean = bean;
	}
}
